package com.fulin.leetcode;

/**
 * TODO
 *
 * @Author fulin
 * @Date 2022/9/23 11:43
 **/
public class Num191_位1的个数 {
    public int hammingWeight(int n){
        int count = 0;
        while(n != 0){
            int r = n & 1;
            count = r == 1 ? ++count : count;
            //这里一定得是无符号右移
            n = n >>> 1;
        }
        return count;
    }
}
